import React, {Component} from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import {observer, inject} from 'mobx-react';

import LoginScreen from '../src/pages/account/login';
import UserInfo from '../src/pages/account/userInfo';
import Demo from './Demo.js';
import TabBar from './pages/tab/TabBar.js';
import TanHua from './pages/tanhua';
import SearchNear from './pages/searchNear';
import TestSoul from './pages/testSoul';
import TestQa from "./pages/testSoul/testQA";
import TestResult from "./pages/testSoul/testResult";
import Detail from './pages/detail';
import Chat from './pages/chat';
import Comments from "./pages/tab/group/comments/Comments";
import Publish from "./pages/tab/group/publish/Publish";
import MyTabNav from './pages/tab/my/MyTabNav.js';
import Trend from './pages/tab/my/trend/Trend.js';
import Visitors from './pages/tab/my/visitors/index.js';
import UserUpdate from './pages/tab/my/userUpdate/index.js';
import Setting from './pages/tab/my/setting'

const Stack = createStackNavigator();

@inject('RootStore')
@observer
class Nav extends Component{
  constructor(props){
    super(props);
    this.state = {
      initialRouteName : this.props.RootStore.token ? 'tabBar' : 'login',
    }
  }

  render(){
    let {initialRouteName} = this.state;
    return (
      <NavigationContainer>
        <Stack.Navigator initialRouteName={initialRouteName} headerMode="none">
          <Stack.Screen name="login" component={LoginScreen} />
          <Stack.Screen name="userInfo" component={UserInfo} />
          <Stack.Screen name="demo" component={Demo} />
          <Stack.Screen name="tabBar" component={TabBar} />
          <Stack.Screen name="tanHua" component={TanHua} />
          <Stack.Screen name="searchNear" component={SearchNear} />
          <Stack.Screen name="testSoul" component={TestSoul} />
          <Stack.Screen name="testQa" component={TestQa} />
          <Stack.Screen name="testResult" component={TestResult} />
          <Stack.Screen name="detail" component={Detail} />
          <Stack.Screen name="chat" component={Chat} />
          <Stack.Screen name="comments" component={Comments} />
          <Stack.Screen name="publish" component={Publish} />
          <Stack.Screen name="myTabNav" component={MyTabNav} />
          <Stack.Screen name="trend" component={Trend} />
          <Stack.Screen name="visitors" component={Visitors} />
          <Stack.Screen name="userUpdate" component={UserUpdate} />
          <Stack.Screen name="setting" component={Setting} />
        </Stack.Navigator>
      </NavigationContainer>
    );
  }
}

export default Nav;
